<template>
	<view class="report-list">
    
    <!-- <template v-if="reportTimeType=='day'">
       <ReportListBlock
         v-for="item in list"
         :key="item.type"
         :isrc="item.isrc"
         :title="item.title"
         :desc="item.desc"
         @tap="setReportType(item.type)"
       ></ReportListBlock>
    </template> -->
    
    <div v-if="reportTimeType=='month'" class="list-bg">
      <image
        src="../../static/img/report-bg.png" 
        mode="widthFix"
        class="__bg"
      ></image>
      <view style="text-align: center;">
        月报暂未开放分类分析报告哦～
      </view>
    </div>
    
    
    <view class="block-other">
      <view class="other-left">
        <view class="__title">月综合报告</view>
        <view class="__desc">包括匹配结果，图片对比等内容</view>
      </view>
      <picker
        mode="date" 
        :fields="reportTimeType"
        :value="showTime"
        :start="star" 
        :end="today"
        @change="changeDateTime"
      >
        <button class="other-right">查看</button>
      </picker>
      <!-- <button v-if="url" class="other-right" data-name="shareBtn" open-type="share">分享</button> -->
    </view>
    
	</view>
</template>

<script>
  import {mapState} from 'vuex'; 
  // import ReportListBlock from './components/ReportListBlock.vue'
  import { getYMD } from '@/common/utils/index.js'
  
	export default {
		components:{
      // ReportListBlock
		},
		data () {
			return {
        reportTimeType:'month',
        start:'',
        showTime:'',
        url:'',
        params:{
          token:'',
          date:''
        },
        token:'',
				list:[]
			}
		},
    computed:{
      ...mapState({
        userInfo:state=>state.userInfo
      }),
      reportText(){
        let text = ''
        switch(this.reportTimeType){
          case 'day':
            text = '日报';
            break;
          case 'month':
            text = '月报';
            break;
          default:
        }
        return text
      }
    },
		onLoad(e) {
      // 页面pv事件埋点
      this.$aplus.aplus_queue.push({
        'action':'aplus.sendPV',
        'arguments':[{
          is_auto: false
        }, {
          sapp_id:'19344',//isv根据实际填写自己应用的参数
          sapp_name:'zhongdianchelian',//isv根据实际填写自己应用的参数
          // 自定义PV参数key-value键值对，以下内容必填，根据应用实际情况设置。
          page_id: 'reportList',//isv根据实际填写自己应用的参数
          page_name: '报表列表',//isv根据实际填写自己应用的参数
          page_url: 'pages/reportList/reportList'//isv根据实际填写自己应用的参数
        }]
      })
			this.reportTimeType = 'month'
      // this.reportTimeType = e.reportTimeType
      uni.getStorage({
        key: 'token',
        success: (res) => {
          this.token = res.data
          this.params.token = res.data
        }
      })
      this.start = getYMD(-60)
      this.today = getYMD()
		},
		onShow () {},
		onHide () {},
		onUnload () {},
    onShareAppMessage(options){
      console.log('onShareAppMessage',options)
      const title = `${this.userInfo.nickname} ${this.showTime} ${this.reportText}分析`
      const params = JSON.stringify(this.params)

      let shareObj = {
        title: title,
        path:`/pages/reportPage/reportPage?params=${params}`,
        imageUrl: '/static/img/report-share.png',
        success:(res)=>{
          if(res.errMsg == 'shareAppMessage:ok'){
            uni.showToast({
              title:'分享成功'
            })
          }
        },
        fail:(err)=>{
          console.log('err',err)
        }
      }
      if(options.from =='button'){
        const eData = options.target.dataset
        // console.log('button',eData)
      }
      return shareObj
    },
		methods: {
      changeDateTime(e){
        // console.log('t',e)
        this.showTime = e.detail.value
        
        switch(this.reportTimeType){
          case 'day':
            this.url =`${this.$config.reportPageUrl}token=${this.token}&date=${this.showTime}`
            break;
          case 'month':
            this.url =`${this.$config.reportPageUrlMonth}token=${this.token}&date=${this.showTime}-01`
            break;
          default:
        }
        
        this.params = {
          url:encodeURIComponent(this.url)
        }
        const params = JSON.stringify(this.params)
        // console.log('params',params)
        uni.navigateTo({
          url:`../reportPage/reportPage?params=${params}`
        })
      },
			setReportType(reportType){
        uni.navigateTo({
          url:`../reportPage/reportPage?reportTimeType=${this.reportTimeType}&reportType=${reportType}`
        })
      }
		}
	}
</script>

<style lang="scss">
	.report-list{
    padding:32rpx;
    min-height: 100vh;
    background: #F5F5F5;
    .list-bg{
      width: 80%;
      margin:0 auto;
      image{
        width: 100%;
        
      }
    }
    .block-other{
      width: 100%;
      height: 130rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding:32rpx;
      box-sizing: border-box;
      position: fixed;
      left: 0;
      bottom: 0;
      background-color: #fff;
      z-index: 100;
      .other-left{
        .__title{
          font-size: 32rpx;
          color:#000;
          margin-bottom: 4rpx;
        }
        .__desc{
          font-size: 24rpx;
          color:#999;
        }
      }
      .other-right{
        width: 152rpx;
        height: 68rpx;
        line-height: 68rpx;
        border-radius: 40rpx;
        border:1px solid blue;
        font-size: 30rpx;
        color: blue;
        text-align: center;
        background-color: #fff;
        margin: 0;
      }
    }
  }
</style>
